const headers = {
    'Accept': 'application/json',
    'Content-Type': 'application/json'
}

export default {
    upload({url,fileUri,fileInput="uploader"}) {
        let formData = new FormData();
        let file = {uri: fileUri, type: 'multipart/form-data', name: fileUri.split("/").pop()};
        formData.append(fileInput, file);
        return fetch(url, {
            method: 'POST',
            headers: {
                'Content-Type': 'multipart/form-data',
            },
            body: formData
        })
            .then((response) => response.json())
    },
    post(url, data, header = headers){
        return fetch(url, {
            method: 'POST',
            headers: header,
            body: JSON.stringify(data)
        }).then(data=> data.json())
    },
    fetch(url){
        return fetch(url, {
            headers: headers
        }).then(data=> data.json())
    },

}